<template>
  <div
    style="
      height: 50px;
      line-height: 50px;
      border-bottom: 1px solid #ccc;
      display: flex;
    "
  >
    <div
      style="
        width: 200px;
        padding-left: 30px;
        font-weight: bold;
        color: dodgerblue;
      "
    >
      水果管理系统
    </div>
    <div style="flex: 1">
      <p class="sj">当前登录时间：<span id="shijian" class="time"></span></p>
    </div>
    <div style="width: 100px">
      <el-dropdown>
        <span class="el-dropdown-link">
          <el-avatar
            :size="30"
            src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
            style="position: relative; top: 10px"
          ></el-avatar>
          {{ user.nickName }}
          <i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="$router.push('/person')"
              >个人信息</el-dropdown-item
            >
            <el-dropdown-item @click="$router.push('/password')"
              >修改密码</el-dropdown-item
            >
            <el-dropdown-item @click="$router.push('/login')"
              >退出系统</el-dropdown-item
            >
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
setInterval(
  "shijian.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",
  1000
);

setInterval(
  "shijian.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",
  1000
);
export default {
  name: "Header",
  props: ["user"],
  data() {
    return {
      // user: {},
    };
  },
  created() {
    // let userStr = sessionStorage.getItem("user") || "{}";
    // this.user = JSON.parse(userStr);
  },
};
</script>

<style scoped>
.sj {
  /*border: #00a7d0 2px solid;*/
  height: auto;
  width: auto;
  position: absolute;
  top: -12px;
  right: 120px;
}
.time {
  font-size: 20px;
  font-weight: 500;
}
</style>
